<template>
  <div class="top">
    <div class="left">
      <div class="left-btn" @click="backHome">首页</div>
    </div>
    <div class="center">智慧旅游可视化大数据展示平台</div>
    <div class="right">
      <div class="right-btn">统计报告</div>
      <div class="time">当前时间：{{ time }}</div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted, onBeforeUnmount } from 'vue'
import { useRouter } from 'vue-router'
import moment from 'moment'

// 点击首页的时候去跳转到首页
// 获取路由对象
const $router = useRouter()
const backHome = () => {
  $router.push('/')
}

// 右边的时间
// 存储当前的时间
const time = ref(moment().format('YYYY年MM月DD日:hh时mm分ss秒'))
let timer: number

onMounted(() => {
  timer = setInterval(() => {
    time.value = moment().format('YYYY年MM月DD日:hh时mm分ss秒')
  }, 1000)
})
// 卸载的时候清除计时器
onBeforeUnmount(() => {
  clearInterval(timer)
})
</script>

<style lang="scss" scoped>
.top {
  height: 100%;
  // background-color: green;
  display: flex;
  .left {
    flex: 1;
    background: url('@/view/screen/images/dataScreen-header-left-bg.png')
      no-repeat;
    display: flex;
    justify-content: end;
    .left-btn {
      font-size: 18px;
      height: 40px;
      text-align: center;
      line-height: 42px;
      cursor: pointer;
      color: $base-screen-button-font-color;
      width: 135px;
      background: url('@/view/screen/images/dataScreen-header-btn-bg-l.png');
    }
  }
  .center {
    font-size: 30px;
    line-height: 74px;
    text-align: center;
    color: $base-screen-button-font-color;
    height: 74px;
    flex: 2;
    background: url('@/view/screen/images/dataScreen-header-center-bg.png')
      no-repeat center center/100% 100%;
    // background-color: blueviolet;
  }
  .right {
    flex: 1;
    background: url('@/view/screen/images/dataScreen-header-right-bg.png')
      no-repeat right top;
    display: flex;
    .right-btn {
      font-size: 18px;
      height: 40px;
      text-align: center;
      line-height: 42px;
      cursor: pointer;
      color: $base-screen-button-font-color;
      width: 135px;
      background: url('@/view/screen/images/dataScreen-header-btn-bg-r.png');
    }
    .time {
      flex: 1;
      color: $base-screen-button-font-color;
      cursor: pointer;
      text-align: center;
      line-height: 40px;
    }
  }
}
</style>
